<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>01axiosgetgrades</title>
    <script type="text/javascript" src="../js/vue.js"></script>
    <script type="text/javascript" src="../js/vue-router.js"></script>
    <script type="text/javascript" src="../js/axios.min.js"></script>
</head>
<body>
    <div id="app">
        <button @click="getAllGrades()">获取所有班级信息</button>
        <div>
            <ul>
                <li v-for="grade in grades">{{grade.name}}</li>
            </ul>
        </div>
    </div>
</body>
</html>
<script>
    var vm=new Vue({
        el:'#app',
        data:{
            url:"http://localhost/grade/getAllGrades",
            grades:[]
        },
        methods:{
            getAllGrades(){
                axios.get(this.url).then(res=>{
                    this.grades=res.data.data.grades;
                });
            }
        }
    });
</script>